<?php

namespace App\Admin\Actions\GoldProductAction;

use App\Supports\Withdraw\Withdrawer;
use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use App\Services\BatchTerminateGoldProducts\BatchTerminateGoldProducts;

class BatchTerminate extends BatchAction
{
	public $name = '批量下次终结';
	
	public function handle(Collection $collection)
	{
		if ($collection->count() > 100) {
			return $this->response()->error('每次最多处理100条');
		}
		
		app(BatchTerminateGoldProducts::class, [
			'collection' => $collection
		])->terminate();
		
		return $this->response()->success('批量终结已提交')->refresh();
	}
}
